import os
import fire
import logging
import cfg4py
from shared import Console


class Command:
    version = '0.0.1'
    env = 'production'
    debug = False
    root_dir = ''
    config = {}

    def __init__(self, root_dir, env='production', debug=False):
        self.env = env
        self.debug = debug
        self.root_dir = root_dir
        self.loadConfig()

    def loadConfig(self):
        cfg = cfg4py.init(os.path.join(self.root_dir, 'shared/cfg4py/resources'))
        self.config = cfg

    def ver(self):
        print('version: ', self.version)

    def info(self):
        Console.success(self)

    def run(self):
        print('run....', logging.DEBUG)


def main(root_dir, env='production', debug=False):
    cmd = Command(root_dir, env, debug)
    fire.Fire({'run': cmd.run, 'info': cmd.info, '--version': cmd.ver, '-v': cmd.ver})


if __name__ == "__main__":
    main()
